package org.pluslibs.framework.swingplus.factory;

import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

import org.pluslibs.framework.swingplus.utils.replace.FileUtils;

public class JButtonsFactory {

    public static JButton buildButton(JButtonIconInterface type) {
        return buildButton(type, type.getName());
    }

    public static JButton buildButton(JButtonIconInterface type, String toolTip) {
        JButton jButton = new JButton(FileUtils.createImageIcon(type.getFileNameAbsolute(), type.getName()));
        jButton.setToolTipText(toolTip);
        jButton.setPreferredSize(new Dimension(25, 25));
        return jButton;
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setSize(new Dimension(100, 100));
        JPanel panel = new JPanel();
        panel.add(buildButton(JButtonCommonIcons.ADD));
        frame.add(panel);
        frame.setVisible(true);
    }
}
